<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/tld/flowdictionary" prefix="flowdictionary"%>
<%@ taglib uri="/tld/dictionary" prefix="dictionary"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link rel="stylesheet" href="${ctx}/static/css/style.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/style1.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/kongjian.css" type="text/css" /> 
<script src="${ctx}/static/script/jquery-1.4.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx}/static/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/static/script/jquery.blockUI.js"></script>
 <title>订单管理</title>
<script language="JavaScript">
	function jumpPage(pageNo) {
		document.getElementById('pageNo').value=pageNo;
		document.getElementById('mainForm').submit();
	}
</script>
<script language="JavaScript">

function submit_(_v,vaction){
	var thisform = document.getElementById('mainForm');
	thisform.action = vaction;//;
	document.getElementById('orderId').value=_v;
	document.getElementById('investId').value=_v;
	document.getElementById('pageNo').value = 1;
	thisform.submit();
}
function orderexec(_v,vaction){
	var thisform = document.getElementById('mainForm2');
	thisform.action = vaction;//;
	thisform.orderId.value=_v;
	thisform.investId.value=_v;
	thisform.submit();
}


$(document).ajaxStop($.unblockUI); 
function replyOrder(orderId){
	var isTrue = confirm('确定要撤单吗？');
	if(isTrue==false){
		return ;
	}
	$.blockUI({ message: '<div><img src="${ctx}/static/images/busy.gif" /><font size="4px"> Just a moment...</font></div>' }); 
	$.get("${ctx}/order/reply_order?orderId="+orderId+'&isOrder=true', function(data) {
		if(data.errorMsg!=null){
			alert(data.errorMsg);
		}
		var thisform = document.getElementById('mainForm');
		thisform.submit();
	});
}

</script>
</head>

<body>
<form:form id="mainForm" action="${ctx}/recommend/recommend_list" modelAttribute="orderListForm" method="post">
<input type="hidden" name="orderId" id="orderId" value="${orderId}"/>
<input type="hidden" name="investId" id="investId" value="${investId}"/>
<div class="er_banner">订单管理</div>
   <div class="shenqing2">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
	      <tr>
            <td width="70">客户编号：</td>
            <td width="140px" style="color:#2E74D1;"><input type="text" id="custmerNo" name="custmerNo" class="ggkj_inputtext_80" value="${orderListForm.custmerNo}" /></td>
            <td width="85">客户姓名：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" id="customerName" name="customerName"  class="ggkj_inputtext_80" value="${orderListForm.customerName}" />
            </td>
			<td width="85">投资编号：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text"  id = "investId_" name="investId_" class="ggkj_inputtext_80" value="${orderListForm.investId_}" />
            </td>
			<td width="85">协议日期：</td>
            <td width="250px" style="color:#2E74D1;">
            <input type="text" id="investstartDate" name="investstartDate" value="${orderListForm.investstartDate}" size="10" onClick="WdatePicker()" readonly="true"/>
            -
            <input type="text" id="investendDate" name="investendDate" value="${orderListForm.investendDate}" size="10" onClick="WdatePicker()" readonly="true"/>
            </td>
			 <td width="93"><input name="Input" type="submit" class="chaxun_btn" value="&nbsp;&nbsp;查询" />
             </td>
          </tr>
      </table>
    </div>
    
<div class="yiban">
	<table style="width:100%;" class="ggkj_table"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col">序号</th>
     <th scope="col">客户编号</th>
    <th scope="col">订单编号</th>
    <th scope="col">投资编号</th>
    <th scope="col">客户姓名</th>
    <th scope="col">约定交割日</th>
    <th scope="col">约定日对价</th>
    <th scope="col">推荐金额</th>
    <th scope="col">已订购金额</th>
    <th scope="col">订购比例</th>
	<th scope="col">状态</th>
    <th scope="col">操作</th>
  </tr>
	<c:forEach items="${page.result}" var="item" varStatus="stauts">
  			<c:if test="${stauts.count%2==0}">
  				<tr class="ggkj_tdColr">
  			</c:if>
  			<c:if test="${stauts.count%2!=0}">
  				<tr >
  			</c:if>
			  <td>${stauts.count+(page.pageNo-1)*10}</td>
			  <td>${item.investInfo.customerInfo.customerCode}</td>
			  <td>${item.id}</td>
			  <td>${item.investInfo.id}</td>
			  <td><a href="#" onclick="submit_('${item.id}','${ctx}/recommend/recommend_detail')">${item.investInfo.customerInfo.cnName}</a></td>
			  <td><fmt:formatDate value="${item.appointPaymentDate}"   pattern="yyyy-MM-dd" type="date" dateStyle="long" /></td>
			  <td><fmt:formatNumber value="${item.orderAmt}" pattern="##,###.##" /></td>
			  <td><fmt:formatNumber value="${item.orderAmt}" pattern="##,###.##" /></td>
			  <td>
			  	  <fmt:formatNumber value="${item.appAmt}" pattern="##,###.##" />
			  </td>
			  <td>
			  	  <fmt:formatNumber value="${item.dgScal}" pattern="#0.000#" />
			  </td>
			  <td>
			  	<flowdictionary:display code="${item.flowId}" />
			  </td>
			  <td><!-- ${item.investInfo.flowId}||${item.investInfo.regularType}||${item.flowId}||${item.payType}|| -->
			  	<c:if test="${item.investInfo.flowId<02000008}"><!-- 非回款订单 -->
			  		<c:if test="${item.flowId=='03000006'}">
				  		修改<a></a><!-- TODO  -->
					  | 导出<a></a><!-- TODO  -->
					  | 订购
					  | 撤单
				  	</c:if>
		  			<c:if test="${item.flowId=='03000002'}">
				  		修改<a></a><!-- TODO  -->
					  | 导出<a></a><!-- TODO  -->
					  | <a href="#" onclick="orderexec('${item.id}','${ctx}/recommend/recommend_order');">订购</a>
					  | <a href="#" onclick="replyOrder(${item.id});">撤单</a>
				  	</c:if>
			  		<c:if test="${item.flowId=='03000005'}">
				  		修改<a></a><!-- TODO  -->
					  | 导出<a></a><!-- TODO  -->
					  | 订购
					  | <a href="#" onclick="replyOrder(${item.id});">撤单</a>
				  	</c:if>
			  	</c:if>
			  	<c:if test="${item.investInfo.flowId>=02000008}"><!-- 回款订单 -->
			  		<c:if test="${item.investInfo.regularType!=null && item.investInfo.regularType=='00130002'}"><!-- 定投回款 -->
					  		<c:if test="${item.payType=='01'}">
						  		<c:if test="${item.flowId=='03000002'}">
							  		修改<a></a><!-- TODO  -->
								  | 导出<a></a><!-- TODO  -->
								  | <a href="#" onclick="orderexec('${item.id}','${ctx}/recommend/recommend_order');">订购</a>
								  | <a href="#" onclick="replyOrder(${item.id});">撤单</a>
							  	</c:if>
						  		<c:if test="${item.flowId=='03000005'}">
							  		修改<a></a><!-- TODO  -->
								  | 导出<a></a><!-- TODO  -->
								  | 订购
								  | <a href="#" onclick="replyOrder(${item.id});">撤单</a>
							  	</c:if>
							  	<c:if test="${item.flowId=='03000006' }">
							  		修改<a></a><!-- TODO  -->
								  | 导出<a></a><!-- TODO  -->
								  | 订购
								  | 撤单
							  	</c:if>
					  		</c:if>
					  		<c:if test="${item.payType=='03'}">
					  			<c:if test="${item.flowId=='03000002'}">
							  		修改<a></a><!-- TODO  -->
								  | 导出<a></a><!-- TODO  -->
								  | 订购
								  | <a href="#" onclick="replyOrder(${item.id});">撤单</a>
							  	</c:if>
							  	<c:if test="${item.flowId=='03000005'||item.flowId=='03000006'}">
							  		修改<a></a><!-- TODO  -->
								  | 导出<a></a><!-- TODO  -->
								  | 订购
								  | 撤单
							  	</c:if>
					  		</c:if>
					</c:if>
					<c:if test="${item.investInfo.regularType!=null && item.investInfo.regularType=='00130001'}"><!-- 定投回款 -->
						  	<c:if test="${item.flowId=='03000002'}">
						  		修改<a></a><!-- TODO  -->
							  | 导出<a></a><!-- TODO  -->
							  | 订购
							  | <a href="#" onclick="replyOrder(${item.id});">撤单</a>
						  	</c:if>
						  	<c:if test="${item.flowId=='03000005'||item.flowId=='03000006'}">
						  		修改<a></a><!-- TODO  -->
							  | 导出<a></a><!-- TODO  -->
							  | 订购
							  | 撤单
						  	</c:if>
					</c:if>
  				</c:if>
			  </td>
		  </tr>
	</c:forEach>
</table>
	
</div>
<div class="ggkj_pagecontainer">
  <div class="ggkj_pageBGleft">
    	<span class="ggkj_pageBGright"></span>
    	<a href="javascript:jumpPage(1)" class="ggkj_pageUpa">
        
        </a>
        <a href="javascript:jumpPage(${page.prePage})" class="ggkj_pageUp">
        
        </a>
        <span class="ggkj_insertline"></span>
        <span class="ggkj_pageSpan">
        	页<input type="text" id="pageNo" name="pageNo" class="ggkj_inputtext_30" value="${page.pageNo}">OF ${page.totalPages}
        </span>
        <span class="ggkj_insertline"></span>
        <a href="javascript:jumpPage(${page.nextPage})" class="ggkj_pageDown">
        
        </a>
        <a href="javascript:jumpPage(${page.totalPages})" class="ggkj_pageDowna">
        
        </a>
        <span class="ggkj_insertline"></span>
        
    </div>
</div>
</body>
</form:form>
<form:form id="mainForm2" action="${ctx}/recommend/recommend_order" modelAttribute="recommendInfoForm" method="post">
<input type="hidden" name="pageNo" id="pageNo" value="1"/>
<input type="hidden" name="orderId" id="orderId" value="${orderId}"/>
<input type="hidden" name="investId" id="investId" value="${investId}"/>
</form:form>
</body>
</html>
